function toOrderDetail(orderid){
    window.location.href=server_url+"buyerOrder/detail.do?orderId="+orderid;
}
var bl = true;
//取消订单
function cancel(orderid,id,skuNum){
    confirmUtil("取消订单",function(flag){
        if(!flag)return;
        localStorage.setItem('cancalOrder',1);
        var cancelReason = "用户取消订单";
        if(empty(cancelReason)){
            easyAlert("取消原因不能为空");
            return;
        }
        if(cancelReason.lenth > 280){
            easyAlert("取消原因不能超过140个字");
            return;
        }
        if(!chkCancelReson(cancelReason)){
            easyAlert("取消原因不规范!");
            return;
        }
        if(bl){
            bl = false;
        }else{
            return;
        }
        $.ajax({
            type:"post",
            url:server_url+"/rest/buyerOrder/cancelOrder.do",
            data:{userid:userid,orderid:orderid,cancelReason:cancelReason,skuId:id,overPlusNum:skuNum,rand:Math.random()},
            success:function(){
                bl = true;
                easyAlert("取消成功");
                window.location.href=server_url+"/buyerOrder/orders.do";
            }
        });
    })

}
var chkCancelReson = function(cancelReason){
    var reg=/([\u4E00-\u9FA5]|[\uFE30-\uFFA0])+/;
    return reg.test(cancelReason);
}
//确认收货
function confirmOrder(orderid){
    confirmUtil("确认收货",function(flag){
        if(!flag) return;
        $.ajax({
            type:"post",
            url:server_url+"/rest/buyerOrder/confirmOrder.do",
            data:{userid:userid,orderid:orderid,rand:Math.random()},
            success:function(){
                easyAlert("收货成功");
                window.location.href=server_url+"/buyerOrder/orders.do";
            }
        });
    })

}
function evaluateOrder(orderid)
{
    $("#sureOrderId").val(orderid);
    $('#evaluate').removeClass('disno1');
}
//评价
function sure(){
    localStorage.setItem('sureOrder',1);
    var orderid = jQuery("#sureOrderId").val();
    var comment = jQuery("#comment").val();
    if(comment == null || comment == '')
    {
        easyAlert("输点评价内容吧")
        return;
    }
    if(comment.length > 256)
    {
        easyAlert("字数太多")
        return;
    }
    $.ajax({
        type:"post",
        url:server_url+"/rest/buyerOrder/sureOrder.do",
        data:{userid:userid,orderid:orderid,comment:comment,comResult:orderComment,rand:Math.random()},
        success:function(){
            easyAlert("评论成功");
            window.location.href=server_url+"/buyerOrder/orders.do";
        }
    });
}
function payNow(orderid){
    $("#payNow").removeClass("disno1");
    $("#payOrderId").val(orderid)
}
function payMoney(){
    var orderid = $("#payOrderId").val();
    var payImg1 =  $("#img1").attr("src")
    var payImg2 =  $("#img2").attr("src")
    if(payImg1 == "" && payImg2 == "")
    {
        easyAlert("请至少上传一张付款凭证");
        return;
    }
    var remark = $("#remark").val();
    if(remark ==  null ||remark == "")
    {
        easyAlert("请填写付款留言")
        return;
    }
    if(remark.length > 200)
    {
        easyAlert("不要超过100字")
        return;
    }
    $.ajax({
        type:"post",
        url:server_url+"/rest/buyerOrder/payMoney.do",
        data:{userid:userid,orderid:orderid,paidImgUrl1:payImg1,paidImgUrl2:payImg2,paidRemark:remark,rand:Math.random()},
        success:function(){
            easyAlert("付款成功");
            window.location.href=server_url+"/buyerOrder/orders.do";
        }
    });
}